package common;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.data.general.Dataset;

import javax.swing.*;
import java.awt.*;

public class ChartDemo extends ApplicationFrame {

    private ChartPanel chartPanel;

    public ChartDemo(String title) {
        super(title);
        JPanel panel = createDemoPanel();
        panel.setPreferredSize(new Dimension(650, 570));
        setContentPane(panel);
    }

    protected Dataset createDataset() {
        return null;
    }

    protected JFreeChart createChart(Dataset dataset) {
        return null;
    }

    private JPanel createDemoPanel() {
        JFreeChart freeChart = createChart(createDataset());
        chartPanel = new ChartPanel(freeChart);
        chartPanel.setMouseWheelEnabled(true);
        return chartPanel;
    }

    public ChartPanel getChartPanel() {
        return chartPanel;
    }
}
